package com.ds.web.interceptor;

import com.ds.context.JDSActionContext;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class CustomClsInterceptor extends BaseInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        try {
            String euClassName = this.getCustomClassName(request);
            String projectName= this.getProjectName(request);

            List<Map> cssList = new ArrayList<Map>();
            Map<String, String> values = new HashMap<>();
            cssList.add(values);
            JDSActionContext.getActionContext().getContext().put("cssList", cssList);
            this.sendFtl(response, "resources/templates/cls.ftl");
            return false;
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return false;


    }

}